#ifndef GAMEVIEW_H
#define GAMEVIEW_H

#include "game.h"
#include <QWidget>
#include <QSizeF>
#include <QRectF>

class GameView : public QWidget
{
    Q_OBJECT
public:
    explicit GameView(Game *game, QWidget *parent = nullptr);

protected:
    void paintEvent(QPaintEvent *event) override;
    void resizeEvent(QResizeEvent *event) override;
    void mousePressEvent(QMouseEvent *event) override;
    void keyPressEvent(QKeyEvent *event) override;

protected slots:
    void onGameUpdate();
    void onGameStateChanged(Game::State, Game::State);

private:
    void calculateGridSize();
    QRectF getCoordRect(int i, int j);
    QRectF getCoordRect(const QPoint& p);

    Game *game;
    QSizeF gridSize;
};

#endif // GAMEVIEW_H
